interface IPerson {
  name: string
  age: number
  height: number
}
const p: IPerson = {
  name: "why",
  age: 18,
  height: 1.88
}


// 1.索引签名的理解
interface InfoType {
  // 索引签名:可以通过字符串索引,去获取到一个值,也是字符串
  [key: string]: string
}

function getInfo(): InfoType {
  const abc: any = "hhh"
  return abc
}

const info = getInfo()
const name = info["name"]
console.log(info.name, info.age, info.address)


//2.索引签名的案例
interface ICollection {
  [index: number]: string
  length: number
}
function printCollection(collection: ICollection) {
  for (let i = 0; i < collection.length; i++) {
    const item = collection[i];
    console.log(item)
  }
}
const names = ["abc", "cba", "nba"]
const tuple: [string, string] = ["why", "广州"]
printCollection(names)
printCollection(tuple)


export { }